﻿using EPiAbstractions.Community.Blog;
using EPiServer.Community.Blog;
using Moq;
using StructureMap.AutoMocking;
using Xunit;

namespace JoelAbrahamsson.MetaWeblog.Tests
{
    public class GetEntryTests
    {
        [Fact] 
        public void GivenID_GetEntry_ReturnsEntryFromHandler()
        {
            int entryID = 1;
            Entry expectedEntry = new Mock<Entry>().Object;
            MoqAutoMocker<MetaWeblogHandler> metaWebLogHandlerAutoMocker = new MoqAutoMocker<MetaWeblogHandler>();
            Mock<IBlogHandlerFacade> fakeBlogHandlerFacade = Mock.Get(metaWebLogHandlerAutoMocker.Get<IBlogHandlerFacade>());
            fakeBlogHandlerFacade.Setup(facade => facade.GetEntry(entryID)).Returns(expectedEntry);
            MetaWeblogHandler metaWeblogHandler = metaWebLogHandlerAutoMocker.ClassUnderTest;

            Entry returnedEntry = metaWeblogHandler.GetEntry(entryID.ToString());

            Assert.NotNull(returnedEntry);
            Assert.Equal<Entry>(expectedEntry, returnedEntry);
        }
    }
}
